<?php
class ui_saved_default extends ui {
	public function __construct($S, $param) {
		parent::__construct();
		
		if ($this->uid) {
			// Nav
			$S->assign('nav', loadMod('glob/nav/0/0'));
			
			// 参数
			$circle_id		= intval($_GET['cid']);
			$_GET['page']	= ($_GET['page']>1) ? intval($_GET['page']) : 1;
			$limit 		= 10;
			
			// circle 列表
			$data_circle = new data_circle();
			$circles = $data_circle->ls($this->uid, 'member', 'private');
			$current = array (
				'id'	=> 0,
				'title'	=> '',
			);
			if (is_array($circles)) {
				foreach ($circles as $k=>$v) {
					if ($v['id'] == $circle_id) {
						$circles[$k]['is_current'] = true;
						$current	= $v;
					}
				}
				$S->assign('circles', $circles);
				$S->assign('current', $current);
				
				$data_save_article = new data_save_article();
				$articles = $data_save_article->ls_saved_by_me($this->uid, $current['id'], $_GET['page'], $limit);
				// 判断第一页和最后一页
				$is_last = 0;
				if ($_GET['page'] > 1 and empty($articles)) {					// 不是第一页，而且没有数据了，那么一定就是最后一页了
					$is_last = 1;
					$_GET['page'] = $_GET['page'] - 1;
					$articles = $data_save_article->ls_saved_by_me($this->uid, $current['id'], $_GET['page'], $limit);
				}
				$S->assign('is_last', 	$is_last);
				$S->assign('page', 	$_GET['page']);
				$S->assign('articles', 	$articles);
			}
			
			// 当需要直接进入edit状态时
			$S->assign('edit_id', intval($_GET['eid']));
			// 当需要直接进入view状态时
			$S->assign('view_id', intval($_GET['vid']));
		}
	}
}
?>